﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <SolidColorBrush x:Key="ScrollBarDisabledBackground" Color="#F4F4F4"/>
    
    <Style x:Key="ScrollBarButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <!-- The scroll bar colors can be customised here, but by default
    they are based on the zune colors. -->
    <Color x:Key="ScrollBarLightColor">#BFBFBF</Color>
    <Color x:Key="ScrollBarMediumColor">#A7A5A5</Color>
    <Color x:Key="ScrollBarDarkColor">#F10DA2</Color>
    
    <!-- Brushes for the scrollbars, based on the scroll bar colors. -->
    <SolidColorBrush x:Key="ScrollBarLightBrush" Color="{StaticResource ScrollBarLightColor}" />
    <SolidColorBrush x:Key="ScrollBarMediumBrush" Color="{StaticResource ScrollBarMediumColor}" />
    <SolidColorBrush x:Key="ScrollBarDarkBrush" Color="{StaticResource ScrollBarDarkColor}" />

    <!-- The style for scrollbars. Completely customised, so modify with care! -->
    <Style TargetType="{x:Type ScrollBar}">
        <Setter Property="Background" Value="{StaticResource ScrollBarLightBrush}"/>
        <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
        <Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
        <Setter Property="Foreground" Value="{StaticResource ScrollBarDarkBrush}"/>
        <Setter Property="Width" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
        <Setter Property="MinWidth" Value="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"/>
        <Setter Property="Height" Value="Auto"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollBar}">
                    <Grid x:Name="Bg" SnapsToDevicePixels="true" Background="Transparent">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="0.00001*"/>
                        </Grid.RowDefinitions>
                        <Border
                            Width="1" HorizontalAlignment="Center"
                            Background="{TemplateBinding Background}" />
                        <Track x:Name="PART_Track" IsDirectionReversed="true" IsEnabled="{TemplateBinding IsMouseOver}">
                            <Track.DecreaseRepeatButton>
                                <RepeatButton
                                    Command="{x:Static ScrollBar.PageUpCommand}" 
                                    Style="{DynamicResource ScrollBarButton}"/>
                            </Track.DecreaseRepeatButton>
                            <Track.IncreaseRepeatButton>
                                <RepeatButton 
                                    Command="{x:Static ScrollBar.PageDownCommand}" 
                                    Style="{DynamicResource ScrollBarButton}"/>
                            </Track.IncreaseRepeatButton>
                            <Track.Thumb>
                                <Thumb Style="{DynamicResource VerticalZuneThumbStyle}" />
                            </Track.Thumb>
                        </Track>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Background" TargetName="Bg" Value="{StaticResource ScrollBarDisabledBackground}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Horizontal">
                <Setter Property="Background" Value="{StaticResource ScrollBarLightBrush}"/>
                <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false"/>
                <Setter Property="Stylus.IsFlicksEnabled" Value="false"/>
                <Setter Property="Foreground" Value="{StaticResource ScrollBarDarkBrush}"/>
                <Setter Property="Width" Value="Auto"/>
                <Setter Property="Height" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/>
                <Setter Property="MinHeight" Value="{DynamicResource {x:Static SystemParameters.HorizontalScrollBarHeightKey}}"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type ScrollBar}">
                            <Grid x:Name="Bg" Background="Transparent" SnapsToDevicePixels="true">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="0.00001*"/>
                                </Grid.ColumnDefinitions>
                                <Border
                                    Height="1" VerticalAlignment="Center"
                                    Background="{TemplateBinding Background}" />
                                <Track x:Name="PART_Track" IsEnabled="{TemplateBinding IsMouseOver}">
                                    <Track.DecreaseRepeatButton>
                                        <RepeatButton
                                            Command="{x:Static ScrollBar.PageLeftCommand}" 
                                            Style="{StaticResource ScrollBarButton}"/>
                                    </Track.DecreaseRepeatButton>
                                    <Track.IncreaseRepeatButton>
                                        <RepeatButton
                                            Command="{x:Static ScrollBar.PageRightCommand}" 
                                            Style="{StaticResource ScrollBarButton}"/>
                                    </Track.IncreaseRepeatButton>
                                    <Track.Thumb>
                                        <Thumb Style="{DynamicResource HorizontalZuneThumbStyle}" />
                                    </Track.Thumb>
                                </Track>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsEnabled" Value="false">
                                    <Setter Property="Background" TargetName="Bg" Value="{StaticResource ScrollBarDisabledBackground}"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>
    
    <!-- The zune thumb style styles the part of the scrollbar that can be dragged with
    the mouse. It is styled to fade from grey to the zune color when activated, and
    widen from the thin size to make it more visible. -->
    <Style x:Key="VerticalZuneThumbStyle" TargetType="{x:Type Thumb}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                
                <!-- The control template for the thumb - simply a border
                with animated color and size. -->
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border x:Name="thumb" SnapsToDevicePixels="true" Width="3" HorizontalAlignment="Center">
                        <Border.Background>
                            <SolidColorBrush 
                                x:Name="thumbBrush" Color="{StaticResource ScrollBarMediumColor}" />
                        </Border.Background>
                    </Border>
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="ActivateStoryboard" >
                            <ColorAnimation
                                Storyboard.TargetName="thumbBrush"
                                Storyboard.TargetProperty="Color"
                                To="{StaticResource ScrollBarDarkColor}"
                                Duration="0:0:0.2" />
                            <DoubleAnimation
                                Storyboard.TargetName="thumb"
                                Storyboard.TargetProperty="Width"
                                To="30"
                                Duration="0:0:0.2">
                                <DoubleAnimation.EasingFunction>
                                    <CubicEase EasingMode="EaseOut" />
                                </DoubleAnimation.EasingFunction>
                            </DoubleAnimation>
                        </Storyboard>
                        <Storyboard x:Key="DeactivateStoryboard" >
                            <ColorAnimation
                                Storyboard.TargetName="thumbBrush"
                                Storyboard.TargetProperty="Color"
                                To="{StaticResource ScrollBarMediumColor}"
                                Duration="0:0:0.2" />
                            <DoubleAnimation
                                Storyboard.TargetName="thumb"
                                Storyboard.TargetProperty="Width"
                                To="3"
                                Duration="0:0:0.2">
                                <DoubleAnimation.EasingFunction>
                                    <CubicEase EasingMode="EaseOut" />
                                </DoubleAnimation.EasingFunction>
                            </DoubleAnimation>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="true">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource ActivateStoryboard}" />
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource DeactivateStoryboard}" />
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="HorizontalZuneThumbStyle" TargetType="{x:Type Thumb}">
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>

                <!-- The control template for the thumb - simply a border
                with animated color and size. -->
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border x:Name="thumb" SnapsToDevicePixels="true" Height="3" VerticalAlignment="Center">
                        <Border.Background>
                            <SolidColorBrush 
                                x:Name="thumbBrush" Color="{StaticResource ScrollBarMediumColor}" />
                        </Border.Background>
                    </Border>
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="ActivateStoryboard" >
                            <ColorAnimation
                                Storyboard.TargetName="thumbBrush"
                                Storyboard.TargetProperty="Color"
                                To="{StaticResource ScrollBarDarkColor}"
                                Duration="0:0:0.2" />
                            <DoubleAnimation
                                Storyboard.TargetName="thumb"
                                Storyboard.TargetProperty="Height"
                                To="30"
                                Duration="0:0:0.2">
                                <DoubleAnimation.EasingFunction>
                                    <CubicEase EasingMode="EaseOut" />
                                </DoubleAnimation.EasingFunction>
                            </DoubleAnimation>
                        </Storyboard>
                        <Storyboard x:Key="DeactivateStoryboard" >
                            <ColorAnimation
                                Storyboard.TargetName="thumbBrush"
                                Storyboard.TargetProperty="Color"
                                To="{StaticResource ScrollBarMediumColor}"
                                Duration="0:0:0.2" />
                            <DoubleAnimation
                                Storyboard.TargetName="thumb"
                                Storyboard.TargetProperty="Height"
                                To="3"
                                Duration="0:0:0.2">
                                <DoubleAnimation.EasingFunction>
                                    <CubicEase EasingMode="EaseOut" />
                                </DoubleAnimation.EasingFunction>
                            </DoubleAnimation>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsEnabled" Value="true">
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource ActivateStoryboard}" />
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource DeactivateStoryboard}" />
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>